// simple frag shader - simple.frag
#version 150
// OpenGL3.2

precision highp float;

// only input
in vec3 exV;
in vec3 exN;
in vec3 exL;
in vec2 exTexCd;
in vec4 ID_color;

// version > 1.3

struct matStruct{
	vec4 ambient;
	vec4 diffuse;
	vec4 specular;
	float shininess;
};

uniform vec4 light;
uniform matStruct material;
uniform sampler2D textureUnit0;

out vec4 fColor;
out vec4 model_ID;

void main(void){

	vec4 colourMap = texture(textureUnit0,exTexCd);
	// Ambient intensity
	vec4 ambientI = colourMap * vec4(0.3);
	// Diffuse intensity
	vec4 diffuseI = colourMap * vec4(0.9) * max(dot(exN,exL),0);
	// Calculate R - reflection
	vec3 R = normalize(-reflect(exL,exN));
	// Specular intensity
	vec4 specularI = vec4(1.0);
	specularI = (colourMap + specularI) * pow(max(dot(R,exV),0),64);

	//fColor = specularI + diffuseI + ambientI;
	//
	//model_ID = ID_color;
	//screen_pos = 

	model_ID = ID_color;
	
	fColor = specularI + diffuseI + ambientI;
}